/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ems.lib;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class Task {

    public final static String CLOSED = "CLOSED";
    public final static String UNDISPATCHED = "UNDISPATCHED";
    public final static String DISPATCHED = "DISPATCHED";
    private Integer taskId;
    private String type;
    private String description;
    private String location;
    private Integer urgency;
    private String timeCreated;
    private String timeClosed;
    private String status;
    private List<Staff> staffs;

    public Task() {
    }

    public Task(Integer taskId) {
        this.taskId = taskId;
        this.status = Task.UNDISPATCHED;
    }

    public Task(Integer taskId, String type, String description, String location, int urgency,
            String status, List<Staff> staffs, List<Resource> resources) {
        this.taskId = taskId;
        this.type = type;
        this.description = description;
        this.location = location;
        this.status = status;
        this.urgency = urgency;
        this.staffs = staffs;
    }

    public Task(String type, String description, String location, int urgency,
            String status) {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd  hh:mm");
        this.type = type;
        this.description = description;
        this.location = location;
        this.status = status;
        this.urgency = urgency;
        this.timeCreated = sdf.format(cal.getTime());
    }

    public Task(String type, String description, String location, int urgency,
            String status, List<Staff> staffs, List<Resource> resources) {
        this.type = type;
        this.description = description;
        this.location = location;
        this.status = status;
        this.urgency = urgency;
        this.staffs = staffs;
    }

    public Task(int id, String type, String description, String location, int urgency,
            String status, String timecreated, String timeclosed) {
        this.taskId = id;
        this.type = type;
        this.description = description;
        this.location = location;
        this.status = status;
        this.urgency = urgency;
        this.timeCreated = timecreated;
        this.timeClosed = timeclosed;        
    }

    public Integer getTaskId() {
        return taskId;
    }

    public void setTaskId(Integer taskId) {
        this.taskId = taskId;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public Integer getUrgency() {
        return urgency;
    }

    public void setUrgency(Integer urgency) {
        this.urgency = urgency;
    }

    public String getTimeCreated() {
        return timeCreated;
    }

    public void setTimeCreated(String timeCreated) {
        this.timeCreated = timeCreated;
    }

    public String getTimeClosed() {
        return timeClosed;
    }

    public void setTimeClosed(String timeClosed) {
        this.timeClosed = timeClosed;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    /**
     * @return the tasks
     */
    public List<Staff> getStaffs() {
        return staffs;
    }

    /**
     * Get the list of staffs
     * @param staffs
     */
    public void setStaffs(List<Staff> staffs) {
        this.staffs = staffs;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (taskId != null ? taskId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Task)) {
            return false;
        }
        Task other = (Task) object;
        if ((this.taskId == null && other.taskId != null) || (this.taskId != null && !this.taskId.equals(other.taskId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ems.lib.Task[taskId=" + taskId + "]";
    }

    /**
     * @return the type
     */
    public String getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(String type) {
        this.type = type;
    }
}
